home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Applications / Telnet 2.7b5 / source / parse / KrbDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-19  |  9.1 KB  |  261 lines  |  [TEXT/CWIE]

  1. /*
  2.     KrbDriver.h -- Application interface for Kerberos Client (mac system extension)
  3.     This interface can be used as is or it can be accessed at a higher level using
  4.     the c++ interface (Kerberos.h).
  5.     
  6.     Set the compiler def KRB_DRIVER only if you are including krb.h in your code
  7.     (this is only necessary for the driver itself)
  8.     
  9.     
  10.     © Copyright 1992 by Cornell University
  11.     
  12.     Initial coding 1/92 by Peter Bosanko.
  13. */
  14.  
  15. #ifndef _KrbDriver_    
  16. #define    _KrbDriver_
  17.  
  18. /* csCodes for Control Calls */
  19. enum {
  20.     cKrbKillIO = 1,
  21.  
  22.     /* Low level routines, here for compatability with Brown Driver */
  23.     cKrbGetLocalRealm,
  24.     cKrbSetLocalRealm,
  25.     cKrbGetRealm,
  26.     cKrbAddRealmMap,
  27.     cKrbDeleteRealmMap,
  28.     cKrbGetNthRealmMap,
  29.     cKrbGetNthServer,
  30.     cKrbAddServerMap,
  31.     cKrbDeleteServerMap,
  32.     cKrbGetNthServerMap,
  33.     cKrbGetNumSessions,
  34.     cKrbGetNthSession,
  35.     cKrbDeleteSession,
  36.     cKrbGetCredentials,
  37.     cKrbAddCredentials,
  38.     cKrbDeleteCredentials,
  39.     cKrbGetNumCredentials,
  40.     cKrbGetNthCredentials,
  41.             
  42.     /* High Level routines */
  43.     cKrbDeleteAllSessions,
  44.     /* Removes all credentials from storage.                   
  45.        The user will be asked to enter user name and password the next time a ticket is requested */ 
  46.  
  47.     cKrbGetTicketForService,
  48.     /* Gets a ticket and returns it to application in buf
  49.           -> service                Formal Kerberos name of service
  50.           -> buf                    Buffer to receive ticket
  51.           -> checksum                checksum for this service
  52.          <-> buflen                    length of ticket buffer (must be at least 1258 bytes)
  53.          <-  sessionKey                for internal use
  54.          <-  schedule                for internal use                                */
  55.  
  56.     cKrbGetAuthForService,
  57.     /* Similiar to cKrbGetTicketForService except it builds a kerberos "SendAuth" style
  58.        request (with SendAuth and application version numbers preceeding the actual ticket)
  59.           -> service                Formal Kerberos name of service
  60.           -> buf                    Buffer to receive ticket
  61.           -> checksum                checksum for this service
  62.           -> applicationVersion        version number of the application (8 byte string)
  63.           <-> buflen                    length of ticket buffer (must be at least 1258 bytes)
  64.          <-  sessionKey                for internal use
  65.          <-  schedule                for internal use                                */
  66.  
  67.     // Use the same krbHiParmBlock for the routines below that you used to get the ticket for the service.
  68.     // That way the session key and schedule will get passed back to the driver.
  69.     
  70.     cKrbCheckServiceResponse,
  71.     /* Use the return code from this call to determine if the client is properly authenticated
  72.           -> buf                    points to the begining of the server response
  73.           -> buflen                length of the server response
  74.           -> sessionKey            this was returned from cKrbGetTicketForService call    
  75.           -> schedule                "    
  76.           -> checksum                left over from cKrbGetTicketForService call
  77.           -> lAddr                addresses used for service validation...
  78.           -> lPort                "
  79.           -> fAddr                "
  80.           -> fPort                "                                             */
  81.  
  82.     cKrbEncrypt,
  83.     /* Encrypt stream, High level version of cKrbMakePrivate
  84.           -> buf                    points to the begining of stream buffer
  85.           -> buflen                length of the stream buffer
  86.           -> sessionKey            this was returned from cKrbGetTicketForService call    
  87.           -> schedule                "    
  88.           -> lAddr                server uses addresses to confirm who we are...
  89.           -> lPort                "
  90.           -> fAddr                "
  91.           -> fPort                "
  92.           -> encryptBuf            output buffer, allow 26 more bytes than input data            
  93.           <- encryptLength        actual length of output data                            */                
  94.  
  95.     cKrbDecrypt,
  96.     /* Decrypt stream, High level version of cKrbReadPrivate
  97.           -> buf                    points to the begining of stream buffer
  98.           -> buflen                length of the stream buffer
  99.           -> sessionKey            this was returned from cKrbGetTicketForService call    
  100.           -> schedule                "    
  101.           -> lAddr                addresses used to confirm source of message...
  102.           -> lPort                "
  103.           -> fAddr                "
  104.           -> fPort                "
  105.           <- decryptOffset        offset in buf to beginning of application data            
  106.           <- decryptLength        actual length of decrypted data                           */
  107.           
  108.     cKrbCacheInitialTicket,
  109.     /* Gets a ticket for the ticket granting service and optionally another service that you specify.
  110.        This call always prompts the user for a password.  The ticket(s) are placed in the ticket cache
  111.        but are not returned.  Use cKrbGetTicketForService to receive the ticket.
  112.        NOTE: This call is useful for getting a ticket for the password changing service or any other
  113.        service that requires that the user be reauthenticated ( that needs an initial ticket ).
  114.        
  115.           -> service            Formal Kerberos name of service
  116.                                   ( NULL service is OK if you just want a ticket granting ticket ) */
  117.                                 
  118.     cKrbGetUserName,
  119.     /* Get the kerberos name of the user.  If the user is not logged in, returns error cKrbNotLoggedIn.
  120.        
  121.           <- user                Name that user typed in loggin dialog             */
  122.  
  123.     cKrbSetUserName,
  124.     /* Set the kerberos name of the user.  If the user is logged in, cKrbSetUserName logged the user out.
  125.        
  126.           -> user                Name that will be used as default in loggin dialog */
  127.  
  128.     cKrbSetPassword,
  129.     /* Sets the password which will be used the next time a password is needed
  130.         This can be used to bypass the loggin dialog.
  131.         NOTE: Password is cleared from memory after it is used once or
  132.         whenever a cKrbSetUserName or cKrbDeleteAllSessions call is made.
  133.           -> user                    contains password (of current user)            */
  134.  
  135.     cKrbGetDesPointers
  136.     /* Returns a block of pointers to DES routines so the routines can be
  137.         called directly. */
  138.     };
  139.  
  140. /* Password changing service */
  141.  
  142. #define KRB_PASSWORD_SERVICE  "changepw.kerberos"
  143.  
  144. // Error codes
  145. enum {
  146.     cKrbCorruptedFile = -1024,    /* couldn't find a needed resource */
  147.     cKrbNoKillIO,                /* can't killIO because all calls sync */
  148.     cKrbBadSelector,            /* csCode passed doesn't select a recognized function */
  149.     cKrbCantClose,                /* we must always remain open */
  150.     cKrbMapDoesntExist,            /* tried to access a map that doesn't exist (index too large,
  151.                                     or criteria doesn't match anything) */
  152.     cKrbSessDoesntExist,        /* tried to access a session that doesn't exist */
  153.     cKrbCredsDontExist,            /* tried to access credentials that don't exist */
  154.     cKrbTCPunavailable,            /* couldn't open MacTCP driver */
  155.     cKrbUserCancelled,            /* user cancelled a log in operation */
  156.     cKrbConfigurationErr,        /* Kerberos Preference file is not configured properly */
  157.     cKrbServerRejected,            /* A server rejected our ticket */
  158.     cKrbServerImposter,            /* Server appears to be a phoney */
  159.     cKrbServerRespIncomplete,    /* Server response is not complete */
  160.     cKrbNotLoggedIn,            /* Returned by cKrbGetUserName if user is not logged in */
  161.     cKrbOldDriver,                /* old version of the driver */
  162.     
  163.     cKrbKerberosErrBlock = -20000    /* start of block of 256 kerberos errors */
  164.     };
  165.     
  166. // Parameter block for high level calls
  167. struct krbHiParmBlock    {
  168.             char             *service;        /* full name -- combined service, instance, realm */
  169.             char              *buf;
  170.             unsigned long      buflen;
  171.             long             checksum;
  172.             unsigned long    lAddr;
  173.             unsigned short    lPort;
  174.             unsigned long    fAddr;
  175.             unsigned short    fPort;
  176.             unsigned long    decryptOffset;
  177.             unsigned long    decryptLength;
  178.             char             *encryptBuf;
  179.             unsigned long    encryptLength;
  180.             char             *applicationVersion;    /* Version string must be 8 bytes long!     */
  181.             char             sessionKey[8];            /* for internal use                      */
  182.             char            schedule[128];            /* for internal use                      */
  183.             char             *user;
  184. };
  185. typedef struct krbHiParmBlock krbHiParmBlock;
  186. typedef krbHiParmBlock *KrbParmPtr;
  187. typedef KrbParmPtr *KrbParmHandle;
  188.  
  189. /* ********************************************************* */
  190. /* The rest of these defs are for low level calls
  191. /* ********************************************************* */
  192. #ifndef KRB_DRIVER
  193. /* First some kerberos defs */
  194.  
  195. #ifdef notdef
  196. typedef unsigned char des_cblock[8];    /* crypto-block size */
  197.  
  198. /* Key schedule */
  199. typedef struct des_ks_struct { des_cblock _; } des_key_schedule[16];
  200.  
  201. #define C_Block des_cblock
  202. #define Key_schedule des_key_schedule
  203. #endif
  204.  
  205. /* The maximum sizes for aname, realm, sname, and instance +1 */
  206. #define     ANAME_SZ    40
  207. #define        REALM_SZ    40
  208. #define        SNAME_SZ    40
  209. #define        INST_SZ        40
  210.  
  211. /* Definition of text structure used to pass text around */
  212. #define        MAX_KTXT_LEN    1250
  213.  
  214. struct ktext {
  215.     long     length;        /* Length of the text */
  216.     unsigned char dat[MAX_KTXT_LEN];    /* The data itself */
  217.     unsigned long mbz;        /* zero to catch runaway strings */
  218. };
  219.  
  220. typedef struct ktext *KTEXT;
  221. typedef struct ktext KTEXT_ST;
  222.  
  223.  
  224. /* Structure definition for rd_private_msg and rd_safe_msg */
  225.  
  226. struct msg_dat {
  227.     unsigned char *app_data;    /* pointer to appl data */
  228.     unsigned long app_length;    /* length of appl data */
  229.     unsigned long hash;        /* hash to lookup replay */
  230.     long     swap;        /* swap bytes? */
  231.     long    time_sec;        /* msg timestamp seconds */
  232.     unsigned char time_5ms;    /* msg timestamp 5ms units */
  233. };
  234.  
  235. typedef struct msg_dat MSG_DAT;
  236.  
  237. typedef unsigned long u_long;
  238. typedef unsigned short u_short;
  239.  
  240. #endif
  241.  
  242.  
  243. /* Parameter block for low level calls */        
  244. struct krbParmBlock    {
  245.             char    *uName;
  246.             char    *uInstance;
  247.             char    *uRealm;            /* also where local realm or mapping realm passed */
  248.             char    *sName;
  249.             char    *sInstance;
  250.             char    *sRealm;
  251.             char    *host;                /* also netorhost */
  252.             long    admin;                /* isadmin, mustadmin */
  253.             long    *itemNumber;
  254.             long    *adminReturn;        /* when it needs to be passed back */
  255.             void *cred;
  256. };
  257. typedef struct krbParmBlock krbParmBlock;
  258.  
  259. #endif
  260.  
  261.